// positionService.js

import request from '@/utils/request'

const baseUri = '/position'

const positionService = {
  list(serachMap) {
    return request({
      url: `${baseUri}/list`,
      method: 'post',
      data:serachMap
    })
  },

  find(id) {
    return request({
      url: `${baseUri}/find`,
      method: 'get',
      params: { id }
    })
  },

  findAll() {
    return request({
      url: `${baseUri}/findAll`,
      method: 'get'
    })
  },

  add(position) {
    return request({
      url: `${baseUri}/add`,
      method: 'post',
      data: position
    })
  },

  update(id,position) {

      //判断是否有ID，没有就是新增
      if(id===null || id===''){
        return this.add(position)
      }
    return request({
      url: `${baseUri}/update`,
      method: 'post',
      data: position
    })
  },

  remove(id) {
    return request({
      url: `${baseUri}/delete`,
      method: 'get',
      params: { id }
    })
  },

  batchRemove(batchDeleteDto) {
    return request({
      url: `${baseUri}/batchRemove`,
      method: 'post',
      data: batchDeleteDto
    })
  }
}

export default positionService